package com.jsyl.lwbk.web.controller.business;

import com.jsyl.lwbk.business.domain.Integration;
import com.jsyl.lwbk.business.service.IntegrationService;
import com.jsyl.lwbk.common.core.controller.BaseController;
import com.jsyl.lwbk.common.core.domain.AjaxResult;
import com.jsyl.lwbk.common.core.page.TableDataInfo;
import com.jsyl.lwbk.framework.util.ShiroUtils;
import com.jsyl.lwbk.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/business/integration")
public class IntegrationController extends BaseController {

    private String prefix = "business/integration";

    @Autowired
    IntegrationService integrationService;

    @Autowired
    ISysUserService sysUserService;

    @GetMapping()
    public String child(ModelMap mmap) {
        return prefix + "/integrationList";
    }
    /**
     * 修改角色
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        mmap.put("project", integrationService.selectById(id));
        return prefix + "/edit";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo findChildList(Integration integration) {
        startPage();
        List<Integration> list = integrationService.findList(integration);
        return getDataTable(list);
    }

    /**
     * 修改保存角色
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@Validated Integration integration)
    {
        integration.setUpdateUser(ShiroUtils.getLoginName());
        return toAjax(integrationService.updateById(integration));
    }

}
